package fr.upmc.i3s.upmcontact.contents;

import java.util.Date;

public class ChatMessage extends Content {
	
	private static final long serialVersionUID = 4468818166123974214L;
	
	private String messageContent;
	private User from;
	
	public ChatMessage() {
		super();
		this.messageContent = null;
		this.from = null;
	}
	
	public ChatMessage(String id, Date createdAt, Date updatedAt, 
						String messageContent, User from) {
		super(id, createdAt, updatedAt);
		this.messageContent = messageContent;
		this.from = from;
	}

	public String getMessageContent() {
		return messageContent;
	}

	public void setMessageContent(String messageContent) {
		this.messageContent = messageContent;
	}

	public User getFrom() {
		return from;
	}

	public void setFrom(User from) {
		this.from = from;
	}

	@Override
	public int hashCode() {
		return super.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		ChatMessage other = (ChatMessage) obj;
		if (from == null) {
			if (other.from != null)
				return false;
		} else if (!from.equals(other.from))
			return false;
		if (messageContent == null) {
			if (other.messageContent != null)
				return false;
		} else if (!messageContent.equals(other.messageContent))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return super.toString() + " ChatMessage [messageContent=" + messageContent + ", from="
				+ from + "]";
	}
	
}
